import { stringify } from 'qs';
import request from '@/utils/request';

// INV
export async function getByBillId(billId) {
  const urlString = `/api/Inv/getByBillId?billid=${billId}`;
  return request(urlString);
}

export async function addInv(params) {
  return request(`/api/inv/addInv`, {
    method: 'POST',
    body: params,
  });
}

export async function lockInv(params) {
  return request(`/api/inv/lockInv`, {
    method: 'POST',
    body: params,
  });
}
export async function saveInv(params) {
  return request(`/api/inv/saveInv`, {
    method: 'POST',
    body: params,
  });
}

export async function deleteInv(invId) {
  return request(`/api/inv/${invId}`, {
    method: 'DELETE',
  });
}

export async function changeInvFPS(params) {
  return request(`/api/inv/changeInvFPS`, {
    method: 'POST',
    body: params,
  });
}

export async function changeInvTDS(params) {
  return request(`/api/inv/changeInvTDS`, {
    method: 'POST',
    body: params,
  });
}

// INV ITEMS.
export async function getItemsByInvId(invId) {
  const urlString = `/api/InvItem/getByInvId?invId=${invId}`;
  return request(urlString);
}

export async function getItemsByBillId(billId) {
  const urlString = `/api/InvItem/getByBillId?billId=${billId}`;
  return request(urlString);
}
export async function addInvItemBatch(params) {
  return request(`/api/InvItem/addInvItemBatch`, {
    method: 'POST',
    body: params,
  });
}

export async function deleteInvItem(id) {
  return request(`/api/InvItem/${id}`, {
    method: 'DELETE',
  });
}

export async function updateInvItem(params) {
  return request(`/api/InvItem/${params.id}`, {
    method: 'PUT',
    body: params,
  });
}
